package com.zzgc.modules.service.impl;

import com.zzgc.common.dao.AuthDepartDao;
import com.zzgc.common.entity.AuthDepart;
import com.zzgc.modules.service.AuthDepartService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;
import java.util.List;

/**
 * 部门表(AuthDepart)表服务实现类
 *
 * @author makejava
 * @since 2022-12-19 17:23:45
 */
@Service("authDepartService")
public class AuthDepartServiceImpl implements AuthDepartService {
    @Resource
    private AuthDepartDao authDepartDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public AuthDepart queryById(Long id) {
        return this.authDepartDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param authDepart 筛选条件
     * @parampageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public List<AuthDepart> queryByPage(AuthDepart authDepart) {
        //long total = this.authDepartDao.count(authDepart);
        return this.authDepartDao.queryAllByLimit(authDepart);
    }

    /**
     * 根据部门名称查询单条信息
     *
     * @param departName 筛选条件
     * @return 查询结果
     */
    @Override
    public AuthDepart queryByPage(String departName) {
        return this.authDepartDao.queryByName(departName);
    }

    /**
     * 新增数据
     *
     * @param authDepart 实例对象
     * @return 实例对象
     */
    @Override
    public AuthDepart insert(AuthDepart authDepart) {
        this.authDepartDao.insert(authDepart);
        return authDepart;
    }

    /**
     * 修改数据
     *
     * @param authDepart 实例对象
     * @return 实例对象
     */
    @Override
    public AuthDepart update(AuthDepart authDepart) {
        this.authDepartDao.update(authDepart);
        return this.queryById(authDepart.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.authDepartDao.deleteById(id) > 0;
    }

    @Override
    public long count(AuthDepart authDepart) {
        return this.authDepartDao.count(authDepart);
    }

    @Override
    public List<Integer> getAllDepart(String departId) {
        return this.authDepartDao.getAllDepart(departId);
    }


}
